class ClassRoom {
  constructor(address, name, students) {
    this.address = address;
    this.name = name;
    this.students = students;
  }
  entry(newStudent) {
    this.students.push(newStudent);
  }

  // 这个地方的东西，就是可以让别人遍历的东西，可以执行我想要遍历的东西
  [Symbol.iterator](params) {
    let index = 0;
    return {
      next: () => {
        if (index < this.students.length) {
          return { done: false, value: this.students[index++] };
        } else {
          return { done: true, value: undefined };
        }
      },
    };
  }
}
const classroom = new ClassRoom("求是楼1楼222", "计算机与科学", [
  "ke bi",
  "james",
  "curry",
  "xjh",
]);
